"""
单例设计模式
    给我的感觉其实就是内存创建机制的因素
    1. 同一类的对象使用同一个内存空间

错误和异常处理：
    1. 定义：错误，Error，异常
    2.
        try:...except:...
        try:...except Exception as e:...
        try:...except Exception as e:...else:...
        try:...except Exception as e:...finally:...
    3. try:
            num = input
            if not num.isdigit()
                raise ValueError("num必须是数字")
        except Exception as e:
            print("引发异常", repr(e))  # 引发异常 ValueError('num必须是数字')

    4. 断言错误
        assert a != 0       # AssertionError
    5. 自定义异常
        try:
            raise MyException("自定义异常", 1001)
        except MyException as e:
            print(e.name, e.code, type(e))  # 自定义异常 1001 <class '__main__.MyException'>

文件
    读取文件
        步骤：
            1. 打开文件 open()
                open("", mode="r", encoding="")
                open("", mode="rb", encoding="")
                open("", mode="w", encoding="")
                open("", mode="a", encoding="")
                open("", mode="r+", encoding="") 读取和写入
                open("", mode="rb+", encoding="")   读取和写入二进制格式的文件
                open("", mode="wb", encoding="")    只能以二进制格式写入
            2. 读取文件
                read()          返回字符串
                readline()      返回字符串对象
                readlines()     返回列表
            3. 关闭文件
                close()
                flush() close()
    写文件
        1. with - as 自动关闭文件
            with open("", mode="w", encoding="utf-8") as fp1:
                fp1.write("")
                fp1.flush()

    拷贝大型文件
    def copy_big_file(path1,path2):
        fp1 = open(path1, "rb")
        fp2 = open(path2, "ab")
        while True:
            content = fp1.read(1024)
            if not content:
                print("拷贝完成")
                break
            fp2.write(content)
        fp1.close()
        fp2.close()
        fp2.close()

"""
